Vue.directive('haspermi', {
    inserted: function (el, binding) {
        const { value } = binding
        const all_permission = "*:*:*";
        if (value[0]) {
            const permissions = Pms.getSessData("permissions").map(item => item.code)
            if (value && value instanceof Array && value.length > 0) {
                const permissionFlag = value
                const hasPermissions = permissions.some(permission => {
                    return all_permission == permissionFlag || permissionFlag.includes(permission)
                })

                if (!hasPermissions) {
                    el.parentNode && el.parentNode.removeChild(el)
                }
            } else {
                throw new Error(`请设置操作权限标签值`)
            }
        }

    },

})